<template>
  <div class="content relative h-screen">
    <div id="canvasImg" class="absolute h-screen opacity-80"></div>
    <el-container class="h-screen">
      <el-aside
        :width="isCollapse ? '64px' : '200px'"
        :class="[isCollapse ? 'aside' : '']"
      >
        <Menu :isCollapse="isCollapse" />
      </el-aside>
      <el-container>
        <el-header>
          <TwtHeader :isCollapse="isCollapse" @handleClose="handleClose" />
        </el-header>
        <el-main>
          <transition name="why">
            <router-view />
          </transition>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue'
import Menu from '@/components/Menu.vue'
import TwtHeader from '@/components/Header.vue'
import { particlesJS } from 'tsparticles'
import { useStore } from 'vuex'

export default defineComponent({
  name: 'Index',
  components: {
    Menu,
    TwtHeader
  },
  setup() {
    const isCollapse = ref(false)
    const handleClose = (flag: boolean) => {
      isCollapse.value = flag
    }
    onMounted(() => {
      particlesJS.load('canvasImg', '/particles.json', () => {
        console.log('OK')
      })
    })
    return {
      isCollapse,
      handleClose
    }
  }
})
</script>

<style scoped>
.el-container,
.el-menu {
  border: 0px;
}
.el-aside {
  overflow-x: hidden;
  background-color: #001529;
}
.aside {
  transition: 0.5s;
}
.el-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
.el-main {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 0;
  overflow-x: hidden;
}

.why-enter-active {
  animation: run 0.5s ease;
}
.why-leave-active {
  animation: run 0.5s ease reverse;
}

@keyframes run {
  0% {
    transform: translateX(120px);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}
</style>
